home *** CD-ROM | disk | FTP | other *** search
- // GETINFO SCRIPTING
- // Imports movies from beyazperde.com with picture
-
- (***************************************************
- * Movie importation script for: *
- * IMDB (US), http://us.imdb.com *
- * *
- * by Tiu Fang to work with (only) beyazperde.com *
- * tiufang@hotmail.com *
- * Based on the IMDB scrit (but does not use *
- * IMDB website at all) *
- * *
- * For use with Ant Movie Catalog 3.4.0 *
- * www.antp.be/software/moviecatalog *
- * *
- * This program is free software; you can *
- * redistribute it and/or modify it under the *
- * terms of the GNU General Public License as *
- * published by the Free Software Foundation; *
- * either version 2 of the License, or (at your *
- * option) any later version. *
- ***************************************************)
-
- program BeyazPerdePic;
- var
- MovieName: string;
-
- function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
- var
- i: Integer;
- begin
- result := -1;
- if StartAt < 0 then
- StartAt := 0;
- for i := StartAt to List.Count-1 do
- if Pos(Pattern, List.GetString(i)) <> 0 then
- begin
- result := i;
- Break;
- end;
- end;
-
- procedure AnalyzePage(Address: string);
- var
- Page: TStringList;
- LineNr: Integer;
- begin
- Page := TStringList.Create;
- Page.Text := GetPage(Address);
- if pos('Arama</title>', Page.Text) = 0 then
- begin
- SetField(fieldURL, Address);
- AnalyzeMoviePage(Page)
- end else
- begin
- PickTreeClear;
- LineNr := 0;
- LineNr := FindLine('<td class="metin3">Filmler</td>', Page, LineNr);
- if LineNr > -1 then
- begin
- PickTreeAdd('Filmler', '');
- AddMoviesTitles(Page, LineNr);
- end;
-
- if PickTreeExec(Address) then
- AnalyzePage(Address);
- end;
- Page.Free;
- end;
-
- procedure AnalyzeMoviePage(Page: TStringList);
- var
- Line, Value, Value2, FullValue: string;
- LineNr: Integer;
- BeginPos, EndPos: Integer;
- begin
-
- // Original Title & Year
- LineNr := FindLine('<title>Beyazperde.com - ', Page, 0);
- Line := Page.GetString(LineNr);
- if LineNr > -1 then
- begin
- BeginPos := pos('<title>Beyazperde.com - ', Line);
- if BeginPos > 0 then
- BeginPos := BeginPos + 24;
- EndPos := pos(' / ', Line);
- if EndPos = 0 then
- begin
- EndPos := pos(' (', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- SetField(fieldTranslatedTitle, Value);
- SetField(fieldOriginalTitle, Value);
- end else
- begin
- BeginPos := pos(' / ', Line) + 3;
- if BeginPos > 0 then
- begin
- EndPos := pos(' (', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- SetField(fieldOriginalTitle, Value);
- end;
- end;
-
- BeginPos := pos('(', Line) + 1;
- if BeginPos > 0 then
- begin
- EndPos := pos(')', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- SetField(fieldYear, Value);
- end;
- end;
-
- // Rating
- LineNr := FindLine('<span class="metin2"><b>SinePuan', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- if Pos('</b>', Line) > 0 then
- begin
- EndPos := pos('</b>', Line);
- BeginPos := pos('tin2>', Line) + 5;
- Value := copy(Line, BeginPos, EndPos - BeginPos);
-
- if pos(',', Value) > 0 then
- begin
- Value := IntToStr(Round(StrToInt(StrGet(Line, BeginPos), 0) + (StrToInt(StrGet(Line, BeginPos + 2), 0) / 10)));
- end;
- SetField(fieldRating, Value);
- end;
- end;
-
- // Picture
- LineNr := FindLine('images/film/', Page, 0);
-
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('src="', Line) + 5;
- EndPos := pos('">', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- GetPicture(Value,False);
- end;
-
- // Director
- LineNr := FindLine('<!-- YONETMEN -->', Page, 0);
- if LineNr > -1 then
- begin
- FullValue := '';
- Line := Page.GetString(LineNr + 4);
-
- BeginPos := pos('item>', Line) + 5;
- EndPos := pos('</a>', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- HTMLDecode(Value);
- SetField(fieldDirector, Value);
- end;
-
- // Actors
- FullValue := '';
- LineNr := FindLine('<!-- OYUNCULAR -->', Page, 0);
-
- if LineNr > -1 then
- begin
- repeat
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
-
- if pos('href="/kisi/', Line) > 0 then
- begin
- BeginPos := pos('class=item>', Line) + 11;
- EndPos := pos('</a>', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- BeginPos := pos('(', Line);
- EndPos := pos(')', Line) + 1;
- Value := Value + ' ' + copy(Line, BeginPos, EndPos - BeginPos) + ', ';
- FullValue := FullValue + Value;
- end;
- until pos('</table>', Line) > 0;
- EndPos := Length(FullValue);
- Delete(FullValue, EndPos - 1, EndPos);
- HTMLDecode(FullValue);
- SetField(fieldActors, FullValue);
- end;
-
- //Country
- LineNr := FindLine('<!-- ULKE -->', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr + 2);
- BeginPos := pos('em>', Line) + 3;
- EndPos := pos('</a>', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- HTMLDecode(Value);
- SetField(fieldCountry, Value);
- end;
-
- //Category
- LineNr := FindLine('arama.asp?kat=tur', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr);
- BeginPos := pos('em>', Line) + 3;
- EndPos := pos('</a>', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- HTMLDecode(Value);
- SetField(fieldCategory, Value);
- end;
-
- // Length
- LineNr := FindLine('<!-- SURESI -->', Page, 0);
- if LineNr > -1 then
- begin
- Line := Page.GetString(LineNr + 2);
- BeginPos := pos(', ', Line) + 2;
- EndPos := pos(' dk', Line);
- Value := copy(Line, BeginPos, EndPos - BeginPos);
- SetField(fieldLength, Value);
- end;
-
-
- //Description
- LineNr := FindLine('<td width="431" colspan="4" bgcolor="#FFFFFF" class=metin align=left valign="middle">', Page, 0);
- Value := '';
- repeat
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- if pos('<p><script src="/beyazperde.js"></script>', Line) < 1 then
- begin
- Value := Value + Line;
- end;
- until pos('<p><script src="/beyazperde.js"></script>', Line) > 0;
-
- Value := StringReplace(Value, '<br>', #13#10);
- Value := StringReplace(Value, '<p>', '');
- Value := StringReplace(Value, #13#10+' ', #13#10);
-
- SetField(fieldDescription, Value);
-
- DisplayResults;
- end;
-
- procedure AddMoviesTitles(Page: TStringList; var LineNr: Integer);
- var
- Line: string;
- MovieTitle, MovieAddress: string;
- StartPos: Integer;
- TempPos: Integer;
- begin
- repeat
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- TempPos := pos('<img src="', Line);
-
- if TempPos < 1 then
- begin
- StartPos := pos('<a href="', Line);
- if StartPos > 0 then
- begin
- Startpos := Startpos + 9;
- MovieAddress := copy(Line, StartPos, pos('" class=metin2>', Line) - StartPos);
- StartPos := pos('<b>', Line) + 3;
- MovieTitle := copy(Line, StartPos, pos('</b>', Line) - StartPos);
- LineNr := LineNr + 1;
- Line := Page.GetString(LineNr);
- StartPos := pos('/ ', Line) + 2;
- MovieTitle := MovieTitle + copy(Line, StartPos, pos ('<br>', Line) - StartPos);
- HTMLDecode(Movietitle);
- PickTreeAdd(MovieTitle, 'http://www.beyazperde.com' + MovieAddress);
- end;
- end;
- until pos('filmden', Line) > 0;
- end;
-
- begin
- if CheckVersion(3,4,0) then
- begin
- MovieName := GetField(fieldOriginalTitle);
- if MovieName = '' then
- MovieName := GetField(fieldTranslatedTitle);
- if Input('Beyaz Perde', 'Lⁿtfen filmin ismini girin', MovieName) then
- begin
- AnalyzePage('http://www.beyazperde.com/hizliarama.asp?keyword='+UrlEncode(MovieName));
- end;
- end else
- ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
- end.
-
-